<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
		<head>
			<!-- template designed by Marco Von Ballmoos -->
			<title>File Source for class.wsdlcache.php</title>
			<link rel="stylesheet" href="../media/stylesheet.css" />
			<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'/>
		</head>
		<body>
						<h1>Source for file class.wsdlcache.php</h1>
<p>Documentation is available at <a href="../nusoap/_class_wsdlcache_php.html">class.wsdlcache.php</a></p>
<div class="src-code">
<pre><ol><li><a name="a1"></a><span class="src-php">&lt;?php</span></li>
<li><a name="a2"></a><span class="src-comm">/*</span></li>
<li><a name="a3"></a><span class="src-comm">The NuSOAP project home is:</span></li>
<li><a name="a4"></a><span class="src-comm">http://sourceforge.net/projects/nusoap/</span></li>
<li><a name="a5"></a>&nbsp;</li>
<li><a name="a6"></a><span class="src-comm">The primary support for NuSOAP is the mailing list:</span></li>
<li><a name="a7"></a><span class="src-comm">nusoap-general@lists.sourceforge.net</span></li>
<li><a name="a8"></a><span class="src-comm">*/</span></li>
<li><a name="a9"></a>&nbsp;</li>
<li><a name="a10"></a><span class="src-doc">/**</span></li>
<li><a name="a11"></a><span class="src-doc">* caches instances of the wsdl class</span></li>
<li><a name="a12"></a><span class="src-doc">* </span></li>
<li><a name="a13"></a><span class="src-doc">* </span><span class="src-doc-coretag">@author</span><span class="src-doc">   Scott Nichol &lt;snichol@users.sourceforge.net&gt;</span></li>
<li><a name="a14"></a><span class="src-doc">* </span><span class="src-doc-coretag">@author</span><span class="src-doc">    Ingo Fischer &lt;ingo@apollon.de&gt;</span></li>
<li><a name="a15"></a><span class="src-doc">* </span><span class="src-doc-coretag">@version</span><span class="src-doc">  $Id: fsource_nusoap__class.wsdlcache.php.html,v 1.2 2010/04/26 20:25:21 snichol Exp $</span></li>
<li><a name="a16"></a><span class="src-doc">* </span><span class="src-doc-coretag">@access</span><span class="src-doc"> public</span></li>
<li><a name="a17"></a><span class="src-doc">*/</span></li>
<li><a name="a18"></a><span class="src-key">class </span><a href="../nusoap/nusoap_wsdlcache.html">nusoap_wsdlcache</a> <span class="src-sym">{</span></li>
<li><a name="a19"></a>    <span class="src-doc">/**</span></li>
<li><a name="a20"></a><span class="src-doc">     *    </span><span class="src-doc-coretag">@var </span><span class="src-doc-type">resource </span></li>
<li><a name="a21"></a><span class="src-doc">     *    </span><span class="src-doc-coretag">@access</span><span class="src-doc"> private</span></li>
<li><a name="a22"></a><span class="src-doc">     */</span></li>
<li><a name="a23"></a>    <span class="src-key">var </span><a href="../nusoap/nusoap_wsdlcache.html#var$fplock">$fplock</a><span class="src-sym">;</span></li>
<li><a name="a24"></a>    <span class="src-doc">/**</span></li>
<li><a name="a25"></a><span class="src-doc">     *    </span><span class="src-doc-coretag">@var </span><span class="src-doc-type">integer </span></li>
<li><a name="a26"></a><span class="src-doc">     *    </span><span class="src-doc-coretag">@access</span><span class="src-doc"> private</span></li>
<li><a name="a27"></a><span class="src-doc">     */</span></li>
<li><a name="a28"></a>    <span class="src-key">var </span><a href="../nusoap/nusoap_wsdlcache.html#var$cache_lifetime">$cache_lifetime</a><span class="src-sym">;</span></li>
<li><a name="a29"></a>    <span class="src-doc">/**</span></li>
<li><a name="a30"></a><span class="src-doc">     *    </span><span class="src-doc-coretag">@var </span><span class="src-doc-type">string </span></li>
<li><a name="a31"></a><span class="src-doc">     *    </span><span class="src-doc-coretag">@access</span><span class="src-doc"> private</span></li>
<li><a name="a32"></a><span class="src-doc">     */</span></li>
<li><a name="a33"></a>    <span class="src-key">var </span><a href="../nusoap/nusoap_wsdlcache.html#var$cache_dir">$cache_dir</a><span class="src-sym">;</span></li>
<li><a name="a34"></a>    <span class="src-doc">/**</span></li>
<li><a name="a35"></a><span class="src-doc">     *    </span><span class="src-doc-coretag">@var </span><span class="src-doc-type">string </span></li>
<li><a name="a36"></a><span class="src-doc">     *    </span><span class="src-doc-coretag">@access</span><span class="src-doc"> public</span></li>
<li><a name="a37"></a><span class="src-doc">     */</span></li>
<li><a name="a38"></a>    <span class="src-key">var </span><a href="../nusoap/nusoap_wsdlcache.html#var$debug_str">$debug_str</a> = <span class="src-str">''</span><span class="src-sym">;</span></li>
<li><a name="a39"></a>&nbsp;</li>
<li><a name="a40"></a>    <span class="src-doc">/**</span></li>
<li><a name="a41"></a><span class="src-doc">    * constructor</span></li>
<li><a name="a42"></a><span class="src-doc">    *</span></li>
<li><a name="a43"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$cache_dir </span><span class="src-doc">directory for cache-files</span></li>
<li><a name="a44"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">integer </span><span class="src-doc-var">$cache_lifetime </span><span class="src-doc">lifetime for caching-files in seconds or 0 for unlimited</span></li>
<li><a name="a45"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@access</span><span class="src-doc"> public</span></li>
<li><a name="a46"></a><span class="src-doc">    */</span></li>
<li><a name="a47"></a>    <span class="src-key">function </span><a href="../nusoap/nusoap_wsdlcache.html#methodnusoap_wsdlcache">nusoap_wsdlcache</a><span class="src-sym">(</span><span class="src-var">$cache_dir</span>=<span class="src-str">'.'</span><span class="src-sym">, </span><span class="src-var">$cache_lifetime</span>=<span class="src-num">0</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a48"></a>        <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#var$fplock">fplock</a> = <span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a49"></a>        <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#var$cache_dir">cache_dir</a> = <span class="src-var">$cache_dir </span>!= <span class="src-str">'' </span>? <span class="src-var">$cache_dir </span>: <span class="src-str">'.'</span><span class="src-sym">;</span></li>
<li><a name="a50"></a>        <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#var$cache_lifetime">cache_lifetime</a> = <span class="src-var">$cache_lifetime</span><span class="src-sym">;</span></li>
<li><a name="a51"></a>    <span class="src-sym">}</span></li>
<li><a name="a52"></a>&nbsp;</li>
<li><a name="a53"></a>    <span class="src-doc">/**</span></li>
<li><a name="a54"></a><span class="src-doc">    * creates the filename used to cache a wsdl instance</span></li>
<li><a name="a55"></a><span class="src-doc">    *</span></li>
<li><a name="a56"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$wsdl </span><span class="src-doc">The URL of the wsdl instance</span></li>
<li><a name="a57"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">string </span><span class="src-doc">The filename used to cache the instance</span></li>
<li><a name="a58"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@access</span><span class="src-doc"> private</span></li>
<li><a name="a59"></a><span class="src-doc">    */</span></li>
<li><a name="a60"></a>    <span class="src-key">function </span><a href="../nusoap/nusoap_wsdlcache.html#methodcreateFilename">createFilename</a><span class="src-sym">(</span><span class="src-var">$wsdl</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a61"></a>        <span class="src-key">return </span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#var$cache_dir">cache_dir</a>.<span class="src-str">'/wsdlcache-' </span>. <a href="http://www.php.net/md5">md5</a><span class="src-sym">(</span><span class="src-var">$wsdl</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a62"></a>    <span class="src-sym">}</span></li>
<li><a name="a63"></a>&nbsp;</li>
<li><a name="a64"></a>    <span class="src-doc">/**</span></li>
<li><a name="a65"></a><span class="src-doc">    * adds debug data to the class level debug string</span></li>
<li><a name="a66"></a><span class="src-doc">    *</span></li>
<li><a name="a67"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@param </span><span class="src-doc">   </span><span class="src-doc-type">string </span><span class="src-doc-var">$string </span><span class="src-doc">debug data</span></li>
<li><a name="a68"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@access</span><span class="src-doc">   private</span></li>
<li><a name="a69"></a><span class="src-doc">    */</span></li>
<li><a name="a70"></a>    <span class="src-key">function </span><a href="../nusoap/nusoap_wsdlcache.html#methoddebug">debug</a><span class="src-sym">(</span><span class="src-var">$string</span><span class="src-sym">)</span><span class="src-sym">{</span></li>
<li><a name="a71"></a>        <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#var$debug_str">debug_str</a> .= <a href="http://www.php.net/get_class">get_class</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">)</span>.<span class="src-str">&quot;</span><span class="src-str">: <span class="src-var">$string</span>\n</span><span class="src-str">&quot;</span><span class="src-sym">;</span></li>
<li><a name="a72"></a>    <span class="src-sym">}</span></li>
<li><a name="a73"></a>&nbsp;</li>
<li><a name="a74"></a>    <span class="src-doc">/**</span></li>
<li><a name="a75"></a><span class="src-doc">    * gets a wsdl instance from the cache</span></li>
<li><a name="a76"></a><span class="src-doc">    *</span></li>
<li><a name="a77"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$wsdl </span><span class="src-doc">The URL of the wsdl instance</span></li>
<li><a name="a78"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">object </span><span class="src-doc-type">wsdl </span><span class="src-doc">The cached wsdl instance, null if the instance is not in the cache</span></li>
<li><a name="a79"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@access</span><span class="src-doc"> public</span></li>
<li><a name="a80"></a><span class="src-doc">    */</span></li>
<li><a name="a81"></a>    <span class="src-key">function </span><a href="../nusoap/nusoap_wsdlcache.html#methodget">get</a><span class="src-sym">(</span><span class="src-var">$wsdl</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a82"></a>        <span class="src-var">$filename </span>= <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#methodcreateFilename">createFilename</a><span class="src-sym">(</span><span class="src-var">$wsdl</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a83"></a>        <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#methodobtainMutex">obtainMutex</a><span class="src-sym">(</span><span class="src-var">$filename</span><span class="src-sym">, </span><span class="src-str">&quot;r&quot;</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a84"></a>            <span class="src-comm">// check for expired WSDL that must be removed from the cache</span></li>
<li><a name="a85"></a>             <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#var$cache_lifetime">cache_lifetime</a> &gt; <span class="src-num">0</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a86"></a>                <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/file_exists">file_exists</a><span class="src-sym">(</span><span class="src-var">$filename</span><span class="src-sym">) </span>&amp;&amp; <span class="src-sym">(</span><a href="http://www.php.net/time">time</a><span class="src-sym">(</span><span class="src-sym">) </span>- <a href="http://www.php.net/filemtime">filemtime</a><span class="src-sym">(</span><span class="src-var">$filename</span><span class="src-sym">) </span>&gt; <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#var$cache_lifetime">cache_lifetime</a><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a87"></a>                    <a href="http://www.php.net/unlink">unlink</a><span class="src-sym">(</span><span class="src-var">$filename</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a88"></a>                    <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#methoddebug">debug</a><span class="src-sym">(</span><span class="src-str">&quot;</span><span class="src-str">Expired <span class="src-var">$wsdl</span> (<span class="src-var">$filename</span>) from cache</span><span class="src-str">&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a89"></a>                    <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#methodreleaseMutex">releaseMutex</a><span class="src-sym">(</span><span class="src-var">$filename</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a90"></a>                    <span class="src-key">return </span><span class="src-id">null</span><span class="src-sym">;</span></li>
<li><a name="a91"></a>                  <span class="src-sym">}</span></li>
<li><a name="a92"></a>            <span class="src-sym">}</span></li>
<li><a name="a93"></a>            <span class="src-comm">// see what there is to return</span></li>
<li><a name="a94"></a>            <span class="src-key">if </span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/file_exists">file_exists</a><span class="src-sym">(</span><span class="src-var">$filename</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a95"></a>                <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#methoddebug">debug</a><span class="src-sym">(</span><span class="src-str">&quot;</span><span class="src-str"><span class="src-var">$wsdl</span> (<span class="src-var">$filename</span>) not in cache (1)</span><span class="src-str">&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a96"></a>                <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#methodreleaseMutex">releaseMutex</a><span class="src-sym">(</span><span class="src-var">$filename</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a97"></a>                <span class="src-key">return </span><span class="src-id">null</span><span class="src-sym">;</span></li>
<li><a name="a98"></a>            <span class="src-sym">}</span></li>
<li><a name="a99"></a>            <span class="src-var">$fp </span>= <span class="src-sym">@</span><a href="http://www.php.net/fopen">fopen</a><span class="src-sym">(</span><span class="src-var">$filename</span><span class="src-sym">, </span><span class="src-str">&quot;r&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a100"></a>            <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$fp</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a101"></a>                <span class="src-var">$s </span>= <a href="http://www.php.net/implode">implode</a><span class="src-sym">(</span><span class="src-str">&quot;&quot;</span><span class="src-sym">, </span><span class="src-sym">@</span><a href="http://www.php.net/file">file</a><span class="src-sym">(</span><span class="src-var">$filename</span><span class="src-sym">))</span><span class="src-sym">;</span></li>
<li><a name="a102"></a>                <a href="http://www.php.net/fclose">fclose</a><span class="src-sym">(</span><span class="src-var">$fp</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a103"></a>                <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#methoddebug">debug</a><span class="src-sym">(</span><span class="src-str">&quot;</span><span class="src-str">Got <span class="src-var">$wsdl</span> (<span class="src-var">$filename</span>) from cache</span><span class="src-str">&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a104"></a>            <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a105"></a>                <span class="src-var">$s </span>= <span class="src-id">null</span><span class="src-sym">;</span></li>
<li><a name="a106"></a>                <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#methoddebug">debug</a><span class="src-sym">(</span><span class="src-str">&quot;</span><span class="src-str"><span class="src-var">$wsdl</span> (<span class="src-var">$filename</span>) not in cache (2)</span><span class="src-str">&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a107"></a>            <span class="src-sym">}</span></li>
<li><a name="a108"></a>            <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#methodreleaseMutex">releaseMutex</a><span class="src-sym">(</span><span class="src-var">$filename</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a109"></a>            <span class="src-key">return </span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/is_null">is_null</a><span class="src-sym">(</span><span class="src-var">$s</span><span class="src-sym">)) </span>? <a href="http://www.php.net/unserialize">unserialize</a><span class="src-sym">(</span><span class="src-var">$s</span><span class="src-sym">) </span>: <span class="src-id">null</span><span class="src-sym">;</span></li>
<li><a name="a110"></a>        <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a111"></a>            <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#methoddebug">debug</a><span class="src-sym">(</span><span class="src-str">&quot;</span><span class="src-str">Unable to obtain mutex for <span class="src-var">$filename</span> in get</span><span class="src-str">&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a112"></a>        <span class="src-sym">}</span></li>
<li><a name="a113"></a>        <span class="src-key">return </span><span class="src-id">null</span><span class="src-sym">;</span></li>
<li><a name="a114"></a>    <span class="src-sym">}</span></li>
<li><a name="a115"></a>&nbsp;</li>
<li><a name="a116"></a>    <span class="src-doc">/**</span></li>
<li><a name="a117"></a><span class="src-doc">    * obtains the local mutex</span></li>
<li><a name="a118"></a><span class="src-doc">    *</span></li>
<li><a name="a119"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$filename </span><span class="src-doc">The Filename of the Cache to lock</span></li>
<li><a name="a120"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$mode </span><span class="src-doc">The open-mode (&quot;r&quot; or &quot;w&quot;) or the file - affects lock-mode</span></li>
<li><a name="a121"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">boolean </span><span class="src-doc">Lock successfully obtained ?!</span></li>
<li><a name="a122"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@access</span><span class="src-doc"> private</span></li>
<li><a name="a123"></a><span class="src-doc">    */</span></li>
<li><a name="a124"></a>    <span class="src-key">function </span><a href="../nusoap/nusoap_wsdlcache.html#methodobtainMutex">obtainMutex</a><span class="src-sym">(</span><span class="src-var">$filename</span><span class="src-sym">, </span><span class="src-var">$mode</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a125"></a>        <span class="src-key">if </span><span class="src-sym">(</span>isset<span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#var$fplock">fplock</a><span class="src-sym">[</span><a href="http://www.php.net/md5">md5</a><span class="src-sym">(</span><span class="src-var">$filename</span><span class="src-sym">)</span><span class="src-sym">]</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a126"></a>            <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#methoddebug">debug</a><span class="src-sym">(</span><span class="src-str">&quot;</span><span class="src-str">Lock for <span class="src-var">$filename</span> already exists</span><span class="src-str">&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a127"></a>            <span class="src-key">return </span><span class="src-id">false</span><span class="src-sym">;</span></li>
<li><a name="a128"></a>        <span class="src-sym">}</span></li>
<li><a name="a129"></a>        <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#var$fplock">fplock</a><span class="src-sym">[</span><a href="http://www.php.net/md5">md5</a><span class="src-sym">(</span><span class="src-var">$filename</span><span class="src-sym">)</span><span class="src-sym">] </span>= <a href="http://www.php.net/fopen">fopen</a><span class="src-sym">(</span><span class="src-var">$filename</span>.<span class="src-str">&quot;.lock&quot;</span><span class="src-sym">, </span><span class="src-str">&quot;w&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a130"></a>        <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$mode </span>== <span class="src-str">&quot;r&quot;</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a131"></a>            <span class="src-key">return </span><a href="http://www.php.net/flock">flock</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#var$fplock">fplock</a><span class="src-sym">[</span><a href="http://www.php.net/md5">md5</a><span class="src-sym">(</span><span class="src-var">$filename</span><span class="src-sym">)</span><span class="src-sym">]</span><span class="src-sym">, </span><span class="src-id">LOCK_SH</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a132"></a>        <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a133"></a>            <span class="src-key">return </span><a href="http://www.php.net/flock">flock</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#var$fplock">fplock</a><span class="src-sym">[</span><a href="http://www.php.net/md5">md5</a><span class="src-sym">(</span><span class="src-var">$filename</span><span class="src-sym">)</span><span class="src-sym">]</span><span class="src-sym">, </span><span class="src-id">LOCK_EX</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a134"></a>        <span class="src-sym">}</span></li>
<li><a name="a135"></a>    <span class="src-sym">}</span></li>
<li><a name="a136"></a>&nbsp;</li>
<li><a name="a137"></a>    <span class="src-doc">/**</span></li>
<li><a name="a138"></a><span class="src-doc">    * adds a wsdl instance to the cache</span></li>
<li><a name="a139"></a><span class="src-doc">    *</span></li>
<li><a name="a140"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">object </span><span class="src-doc-type">wsdl </span><span class="src-doc-var">$wsdl_instance </span><span class="src-doc">The wsdl instance to add</span></li>
<li><a name="a141"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">boolean </span><span class="src-doc">WSDL successfully cached</span></li>
<li><a name="a142"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@access</span><span class="src-doc"> public</span></li>
<li><a name="a143"></a><span class="src-doc">    */</span></li>
<li><a name="a144"></a>    <span class="src-key">function </span><a href="../nusoap/nusoap_wsdlcache.html#methodput">put</a><span class="src-sym">(</span><span class="src-var">$wsdl_instance</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a145"></a>        <span class="src-var">$filename </span>= <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#methodcreateFilename">createFilename</a><span class="src-sym">(</span><span class="src-var">$wsdl_instance</span><span class="src-sym">-&gt;</span><span class="src-id">wsdl</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a146"></a>        <span class="src-var">$s </span>= <a href="http://www.php.net/serialize">serialize</a><span class="src-sym">(</span><span class="src-var">$wsdl_instance</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a147"></a>        <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#methodobtainMutex">obtainMutex</a><span class="src-sym">(</span><span class="src-var">$filename</span><span class="src-sym">, </span><span class="src-str">&quot;w&quot;</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a148"></a>            <span class="src-var">$fp </span>= <a href="http://www.php.net/fopen">fopen</a><span class="src-sym">(</span><span class="src-var">$filename</span><span class="src-sym">, </span><span class="src-str">&quot;w&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a149"></a>            <span class="src-key">if </span><span class="src-sym">(</span><span class="src-sym">! </span><span class="src-var">$fp</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a150"></a>                <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#methoddebug">debug</a><span class="src-sym">(</span><span class="src-str">&quot;</span><span class="src-str">Cannot write <span class="src-var">$wsdl_instance</span><span class="src-sym">-&gt;</span><span class="src-id">wsdl</span> (<span class="src-var">$filename</span>) in cache</span><span class="src-str">&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a151"></a>                <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#methodreleaseMutex">releaseMutex</a><span class="src-sym">(</span><span class="src-var">$filename</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a152"></a>                <span class="src-key">return </span><span class="src-id">false</span><span class="src-sym">;</span></li>
<li><a name="a153"></a>            <span class="src-sym">}</span></li>
<li><a name="a154"></a>            <a href="http://www.php.net/fputs">fputs</a><span class="src-sym">(</span><span class="src-var">$fp</span><span class="src-sym">, </span><span class="src-var">$s</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a155"></a>            <a href="http://www.php.net/fclose">fclose</a><span class="src-sym">(</span><span class="src-var">$fp</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a156"></a>            <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#methoddebug">debug</a><span class="src-sym">(</span><span class="src-str">&quot;</span><span class="src-str">Put <span class="src-var">$wsdl_instance</span><span class="src-sym">-&gt;</span><span class="src-id">wsdl</span> (<span class="src-var">$filename</span>) in cache</span><span class="src-str">&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a157"></a>            <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#methodreleaseMutex">releaseMutex</a><span class="src-sym">(</span><span class="src-var">$filename</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a158"></a>            <span class="src-key">return </span><span class="src-id">true</span><span class="src-sym">;</span></li>
<li><a name="a159"></a>        <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></li>
<li><a name="a160"></a>            <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#methoddebug">debug</a><span class="src-sym">(</span><span class="src-str">&quot;</span><span class="src-str">Unable to obtain mutex for <span class="src-var">$filename</span> in put</span><span class="src-str">&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a161"></a>        <span class="src-sym">}</span></li>
<li><a name="a162"></a>        <span class="src-key">return </span><span class="src-id">false</span><span class="src-sym">;</span></li>
<li><a name="a163"></a>    <span class="src-sym">}</span></li>
<li><a name="a164"></a>&nbsp;</li>
<li><a name="a165"></a>    <span class="src-doc">/**</span></li>
<li><a name="a166"></a><span class="src-doc">    * releases the local mutex</span></li>
<li><a name="a167"></a><span class="src-doc">    *</span></li>
<li><a name="a168"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$filename </span><span class="src-doc">The Filename of the Cache to lock</span></li>
<li><a name="a169"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">boolean </span><span class="src-doc">Lock successfully released</span></li>
<li><a name="a170"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@access</span><span class="src-doc"> private</span></li>
<li><a name="a171"></a><span class="src-doc">    */</span></li>
<li><a name="a172"></a>    <span class="src-key">function </span><a href="../nusoap/nusoap_wsdlcache.html#methodreleaseMutex">releaseMutex</a><span class="src-sym">(</span><span class="src-var">$filename</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a173"></a>        <span class="src-var">$ret </span>= <a href="http://www.php.net/flock">flock</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#var$fplock">fplock</a><span class="src-sym">[</span><a href="http://www.php.net/md5">md5</a><span class="src-sym">(</span><span class="src-var">$filename</span><span class="src-sym">)</span><span class="src-sym">]</span><span class="src-sym">, </span><span class="src-id">LOCK_UN</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a174"></a>        <a href="http://www.php.net/fclose">fclose</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#var$fplock">fplock</a><span class="src-sym">[</span><a href="http://www.php.net/md5">md5</a><span class="src-sym">(</span><span class="src-var">$filename</span><span class="src-sym">)</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a175"></a>        unset<span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#var$fplock">fplock</a><span class="src-sym">[</span><a href="http://www.php.net/md5">md5</a><span class="src-sym">(</span><span class="src-var">$filename</span><span class="src-sym">)</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a176"></a>        <span class="src-key">if </span><span class="src-sym">(</span><span class="src-sym">! </span><span class="src-var">$ret</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a177"></a>            <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#methoddebug">debug</a><span class="src-sym">(</span><span class="src-str">&quot;</span><span class="src-str">Not able to release lock for <span class="src-var">$filename</span></span><span class="src-str">&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a178"></a>        <span class="src-sym">}</span></li>
<li><a name="a179"></a>        <span class="src-key">return </span><span class="src-var">$ret</span><span class="src-sym">;</span></li>
<li><a name="a180"></a>    <span class="src-sym">}</span></li>
<li><a name="a181"></a>&nbsp;</li>
<li><a name="a182"></a>    <span class="src-doc">/**</span></li>
<li><a name="a183"></a><span class="src-doc">    * removes a wsdl instance from the cache</span></li>
<li><a name="a184"></a><span class="src-doc">    *</span></li>
<li><a name="a185"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$wsdl </span><span class="src-doc">The URL of the wsdl instance</span></li>
<li><a name="a186"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">boolean </span><span class="src-doc">Whether there was an instance to remove</span></li>
<li><a name="a187"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@access</span><span class="src-doc"> public</span></li>
<li><a name="a188"></a><span class="src-doc">    */</span></li>
<li><a name="a189"></a>    <span class="src-key">function </span><a href="../nusoap/nusoap_wsdlcache.html#methodremove">remove</a><span class="src-sym">(</span><span class="src-var">$wsdl</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a190"></a>        <span class="src-var">$filename </span>= <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#methodcreateFilename">createFilename</a><span class="src-sym">(</span><span class="src-var">$wsdl</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a191"></a>        <span class="src-key">if </span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/file_exists">file_exists</a><span class="src-sym">(</span><span class="src-var">$filename</span><span class="src-sym">)) </span><span class="src-sym">{</span></li>
<li><a name="a192"></a>            <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#methoddebug">debug</a><span class="src-sym">(</span><span class="src-str">&quot;</span><span class="src-str"><span class="src-var">$wsdl</span> (<span class="src-var">$filename</span>) not in cache to be removed</span><span class="src-str">&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a193"></a>            <span class="src-key">return </span><span class="src-id">false</span><span class="src-sym">;</span></li>
<li><a name="a194"></a>        <span class="src-sym">}</span></li>
<li><a name="a195"></a>        <span class="src-comm">// ignore errors obtaining mutex</span></li>
<li><a name="a196"></a>        <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#methodobtainMutex">obtainMutex</a><span class="src-sym">(</span><span class="src-var">$filename</span><span class="src-sym">, </span><span class="src-str">&quot;w&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a197"></a>        <span class="src-var">$ret </span>= <a href="http://www.php.net/unlink">unlink</a><span class="src-sym">(</span><span class="src-var">$filename</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a198"></a>        <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#methoddebug">debug</a><span class="src-sym">(</span><span class="src-str">&quot;</span><span class="src-str">Removed (<span class="src-var">$ret</span>) <span class="src-var">$wsdl</span> (<span class="src-var">$filename</span>) from cache</span><span class="src-str">&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a199"></a>        <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../nusoap/nusoap_wsdlcache.html#methodreleaseMutex">releaseMutex</a><span class="src-sym">(</span><span class="src-var">$filename</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a200"></a>        <span class="src-key">return </span><span class="src-var">$ret</span><span class="src-sym">;</span></li>
<li><a name="a201"></a>    <span class="src-sym">}</span></li>
<li><a name="a202"></a><span class="src-sym">}</span></li>
<li><a name="a203"></a>&nbsp;</li>
<li><a name="a204"></a><span class="src-doc">/**</span></li>
<li><a name="a205"></a><span class="src-doc"> * For backward compatibility</span></li>
<li><a name="a206"></a><span class="src-doc"> */</span></li>
<li><a name="a207"></a><span class="src-key">class </span><a href="../nusoap/wsdlcache.html">wsdlcache</a> <span class="src-key">extends </span><a href="../nusoap/nusoap_wsdlcache.html#methodnusoap_wsdlcache">nusoap_wsdlcache</a> <span class="src-sym">{</span></li>
<li><a name="a208"></a><span class="src-sym">}</span></li>
<li><a name="a209"></a><span class="src-php">?&gt;</span></li>
</ol></pre>
</div>
	<p class="notes" id="credit">
		Documentation generated on Mon, 26 Apr 2010 16:16:49 -0400 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.3.0RC3</a>
	</p>
	</body>
</html>